var express = require('express');
var router = express.Router();

const {
  login,
  verify,
  reg,
  noexist,
  captcha,
  vcaptcha,
  myinfo,
  findUsersList,
  findById,
  insert,
  update,
  delById,
  editpwd
} = require("../controller/users");
const { authFilter } = require("../middlewares/auth");

class UsersRouter {
  static initRouter() {
    router.post('/login', login);
    router.get('/verify', verify);
    router.post('/reg', reg);
    router.get('/noexist', noexist);
    router.get('/captcha', captcha);
    router.get('/captcha/:vcode', vcaptcha);
    router.get('/myinfo/:username', authFilter, myinfo);

    router.get('/', authFilter, findUsersList);
    router.get('/:id', authFilter, findById);
    router.post('/0', authFilter, insert);
    router.put('/:id', authFilter, update);
    router.delete('/:id', authFilter, delById);
    router.put('/editpwd/:id', authFilter, editpwd);

    return router;
  }
}
module.exports = UsersRouter.initRouter();